package com.rankeiot.platform.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.sql.Types;
import java.util.Map;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.experimental.FieldNameConstants;
import org.sagacity.sqltoy.config.annotation.*;
import org.hibernate.validator.constraints.Length;


/**
 * 多级字典
 */
@Schema(description = "多级字段")
@Data
@FieldNameConstants(asEnum = true)
@Entity(tableName=MultiDictionary.TABLE)
@Indexes(indexes = {
    @Index(name="idx_parent_sn",columns = {"parent_sn"})
})
public class MultiDictionary implements Serializable{
    public static final String TABLE="t_multi_dictionary";

    /**
     * 编码
     */
    @Schema(description = "编码")
    @Id(strategy = "generator",generator = "snowflake")
    @Length(max=100)
    @Column(name="sn",length=100L,type=Types.VARCHAR,nullable=false)
    private String sn;
    /**
     * 父级编码
     */
    @Schema(description = "父级编码")
    @Column(name="parent_sn",length=255L,type=Types.VARCHAR)
    private String parentSn;
    /**
     * 层级
     */
    @Schema(description = "层级")
    @Column(name="`rank`",length=11L,type=Types.INTEGER)
    private Integer rank;

//    @Schema(description = "子节点数")
//    private Integer subCount;
    /**
     * 名称
     */
    @Schema(description = "名称")
    @Length(max=255)
    @Column(name="name",length=255L,type=Types.VARCHAR)
    private String name;
    /**
     * 自定义编码
     */
    @Schema(description = "自定义编码")
    @Length(max=10)
    @Column(name="code",length=10L,type=Types.VARCHAR)
    private String code;
    /**
     * 更新时间
     */
    @Schema(description = "更新时间")
    @Column(name="update_time",length=19L,type=Types.TIMESTAMP)
    private Date updateTime;
    /**
     * 图标
     */
    @Schema(description = "图标")
    @Length(max=255)
    @Column(name="icon",length=255L,type=Types.VARCHAR)
    private String icon;
    /**
     * 附加属性
     */
    @Schema(description = "附加属性")
    @Column(name="props",length=65535L,type=Types.LONGVARCHAR)
    private Map<String,String> props;

    public MultiDictionary(){}
    public MultiDictionary(String sn){
        this.sn=sn;
    }
}
